package com.module03.Q1_CharCount;

import java.util.ArrayList;

public class Q1_CharCount {

    public static void main(String[] args) {
	// write your code here
        String str="ABCD123!@#$%ab";
        System.out.println("字符串为"+str);
        char[] ch=str.toCharArray();
//      大写字母组
        ArrayList<Character> a1=new ArrayList();
//      小写字母组
        ArrayList<Character> a2=new ArrayList();
//      数字组
        ArrayList<Character> a3=new ArrayList();
//      其他字符组
        ArrayList<Character> a4=new ArrayList();

//      字符分类
        for (char i:ch
             ) {
            if(i>='A' && i<='Z'){
                a1.add(i);
            }else if(i>='a' && i<='z'){
                a2.add(i);
            }else if(i>='0' && i<='9'){
                a3.add(i);
            }else{
                a4.add(i);
            }
        }

//      打印每个List组的内容
        System.out.println("大写字母个数为"+a1.size());
        for (char i:
             a1) {
            System.out.print(i+" ");
        }
        System.out.println();

        System.out.println("小写字母个数为"+a2.size());
        for (char i:
                a2) {
            System.out.print(i+" ");
        }
        System.out.println();

        System.out.println("数字个数为"+a2.size());
        for (char i:
                a3) {
            System.out.print(i+" ");
        }
        System.out.println();

        System.out.println("其他字符个数为"+a4.size());
        for (char i:
                a4) {
            System.out.print(i+" ");
        }
        System.out.println();
    }
}
